<?php



$a = 's:32:"a:1:{i:17449067;s:8:"��Ѷ��ѡ";}";';
$b = unserialize($a);
$c = unserialize($b);
var_export($c);
exit;


$regex = '/s＼:(＼d+)＼:＼"([^＼"]+)＼"/isx';
 
$str = preg_replace_callback(
$regex ,
"fixser",
$a);
 
function fixser($matches)
{
 return 's:'.strlen($matches[2]).':'.'"'.$matches[2].'"';
}

$b = unserialize($str);

var_dump($b);



exit;

$a = [1=>'a',2=>'b',3=>'v',4=>'d'];

unset($a[3]);
var_dump($a);

exit;
$a = [0, 2, 3, 5];
foreach ($a as $key => $value) {
    echo $value;
}

exit();
function test7 (int $a, $n) : int 
{
    return 123;    
}

echo test7(123, 123);

exit;
$a = array (
  0 => 
  array (
    'type' => 8,
    '_id' => 6602266403,
    'title' => '高速上这三个人拿自己的生命在救人，好人一生平安！',
    'imageUrl' => 
    array (
      0 => 'http://mv.xcarimg.com/xbb/pc/qiniu/image/thumb/2018/11/05/o_63cca10a82281965f2e92ac966ec75b0_s1_org.jpg',
    ),
    'subType' => 2,
    'uid' => 11768003,
    'headPortrait' => 'http://image1.xcarimg.com/attachments/my/1/17/68/003_120.jpg?t=1557455840',
    'userName' => '赤手战棕熊',
    'isVip' => 1,
    'mediaType' => '',
    'width' => 852,
    'height' => 480,
    'isPraised' => 0,
    'isFollowed' => 0,
    'isReported' => 0,
    'isCollected' => 0,
    'xbbLevel' => '',
    'logoType' => 0,
    'location' => '',
    'auditState' => 1,
    'showStatus' => 1,
    'softPicCount' => 0,
    'playCount' => '',
    'duration' => '00:49',
    'durationNum' => 49,
    'tvLink' => 'http://mv.xcarimg.com/xbb/pc/qiniu/video/converted/mp4/2018/11/05/mp4_o_63cca10a82281965f2e92ac966ec75b0_auto.mp4',
    'request_id' => '1557455840217',
    'shareInfo' => 
    array (
      'title' => '赤手战棕熊发布了视频',
      'content' => '高速上这三个人拿自己的生命在救人，好人一生平安！',
      'image' => 'http://mv.xcarimg.com/xbb/pc/qiniu/image/thumb/2018/11/05/o_63cca10a82281965f2e92ac966ec75b0_s1_org.jpg',
      'webLink' => 'http://club.xcar.com.cn/xbb/6602266403.html',
    ),
    'softPics' => 
    array (
      'imageUrl' => '',
      'smallImage' => '',
      'height' => 0,
      'width' => 0,
      'ptag' => '',
    ),
  ),
);

$c = array_values($a);
var_export($c);
exit;










echo phpinfo();
exit;

function reverse($x) {
	$count = intval(strlen($x))-1;
	$arr = str_split($x);
	for ($i=$count; $i >= 0; $i--) { 
			# code...
			echo $arr[$i];
		}	


}
reverse(-123);
exit();
$a = ['a','v','c'];
$b = ['a'=>2,'v'=>3,'c'=>4,'d'=>5];
$b = array_flip($b);
$arr = array_intersect($a, $b);
var_dump($arr);


exit();
// echo yield -1;


exit();
$a = array ( 'status' => 1, 'msg' => '数据获取成功', 'data' => array ( 'user' => array ( 'uid' => 11371976, 'name' => '雪花来了', 'introduction' => '哈哈哈哈', 'icon' => 'http://image1.xcarimg.com/attachments/my/1/13/71/976_120.jpg?t=1554096197', 'operateName' => '崔**', 'paperNum' => '222*************21', 'pId' => 1, 'province' => '北京市', 'cId' => 475, 'city' => '北京市', 'operateTel' => '180****8440', 'operateEmail' => 'cuix*@163.com', 'mechanismName' => '不哈哈哈哈', 'mechanismCode' => '哈�*哈哈姐姐', 'type' => 2, 'status' => 2, 'editCount' => 0, 'isEdit' => 1, ), ), );
echo json_encode($a);
exit();

$a = 'http://club.xcar.com.cn/xbb/huati/4885.html';
$b = '/\/xbb\/huati\/([0-9]{0,})/';
preg_match($b, $a,$matches);
var_dump($matches);
exit();

$str = '😝有人吗';
        $a = '/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f])|(\ud83d[\ude80-\udeff])/';
        preg_match_all($a, $str,$matches);
        var_dump($matches);
        exit;
$a = '大小姐（&';
$b = '/\n/';
preg_match($b, $a,$c);
var_export($c);
exit();
if (preg_match($b, $a))
{
	echo 'ok';
}
exit();
function getTaskTimeNew ($time)
{
    $days = 100;

    $stime = date('Y-m-d',$time);
    $newStime = $stime.' 0:0:0';
    $ntime = date('Y-m-d',time());
    $newNtime = $ntime.' 23:59:59';
    $newTime = (strtotime($newNtime) - strtotime($newStime)) / 86400;
    $endTimes = mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
    $times = $endTimes - time();
    switch ($newTime)
    {
        case $newTime < 1:
            $days = 1;
            break;
        case $newTime < 2 && $newTime > 1:
            $days = 2;
            break;
        case $newTime < 3 && $newTime > 2:
            $days = 3;
            break;
        case $newTime < 4 && $newTime > 3:
            $days = 4;
            break;
        case $newTime < 5 && $newTime > 4:
            $days = 5;
            break;
        case $newTime < 6 && $newTime > 5:
            $days = 6;
            break;
        case $newTime < 7 && $newTime > 6:
            $days = 7;
            break;
        default:
            break;
    }
    return [
        'days' => $days,
        'times' => $times
    ];
}

$a = getTaskTimeNew(1553247777);
var_export($a);
exit;
$name = 'xuser123';
$checkXuser = substr($name,0,5);
echo $checkXuser;
        if ($checkXuser == 'xuser')
        {
           echo '123';
        }
exit;

$b = '2019-03-22 23:59:59';
$c = '2015-05-20 15:21:23';
echo strtotime($b);
exit;


$a = '123xuser123';
echo strpos($a, 'xuser');
exit;
function checkEmail($email)
{
	if (empty($email)) return false;
	$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/";
	preg_match($pattern, $email, $matches);
	return $matches;
}

$a = "yechenliang@qq.com";

$b = checkEmail($a);
var_export($b);
exit();

echo strtotime('2019-03-20 59:59:59');
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
echo $endToday;
exit();

echo date('Y-m-d H:i:s',1552556497);
exit;
// $cc = '382828@qq.com';

     function replaceWords123 ($string,$start,$end,$type = 1)
    {
        $len = mb_strlen($string);
        if ($end != 0)
        {
            $newEnd = $end - $start;
        } else
        {
            $newEnd = $len;
        }
        if ($type == 1) 
        {	
        	for ($i=$start; $i <=$end ; $i++) { 
        		$string[$i] = '*';
        	}
        	$newString = $string;
        }else {
        	$replace = mb_substr($string,$start,$newEnd);
        	$replaceLen = mb_strlen($replace);
        	$replaceStr = "";
	        for ($i = 0;$i < $replaceLen;$i++)
	        {
	            $replaceStr .= "*";
	        }
	        $newString = str_replace($replace,$replaceStr,$string);
        }
        
        return $newString;
    }
    echo replaceWords123('382828@qq.com',4,6);
    // echo replaceWords123('382828@qq.com',4,5);
    exit;

$a = '1 2';
$b = '/\s/';
$c = preg_match($b,$a);
var_dump($c);
exit;

function checkIdNum ($num, $type)
{
    //校验身份证
    if ($type ==1)
    {
        $pattern = '/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/';
    } else
    {
        $pattern = '/^[0-9A-Z]{9}/';
    }
    if (preg_match($pattern,$num,$match))
    {
        return true;
    }

    return false;  //证件号码有问题


}

$a = '到家大';
$b = checkIdNum($a,1);
var_export($b);
exit();


function replaceWords ($string,$start,$end)
    {
        $len = mb_strlen($string);
        if ($end == 0)
        {
            $end = $len;
        } else
        {
        	$end = $end - $start;
        }

        $replace = mb_substr($string,$start,$end);
        $replaceLen = mb_strlen($replace);
        $replaceStr = "";
        for ($i = 0;$i < $replaceLen;$i++)
        {
            $replaceStr .= "*";
        }
        $newString = str_replace($replace,$replaceStr,$string);
        echo $newString;
    }

$a = "时羽哈哈";
$b = '1234567890123456778';
$c = '12345675@.qq.com';
replaceWords($a,1,0);

exit;
$a = 'shiyu';
$b = '时羽';
echo strlen($a);
echo strlen($b);
echo mb_strlen($a);
echo mb_strlen($b);
exit;

echo base64_encode('/Users/ye/Desktop/1551423091618.jpg');
exit;
echo date('Y-m-d : H:i:s',1548157451);
exit;
echo time();
exit;
$time    = strtotime("-3 day");
        $day     = date('Y-m-d',$time);
        $newDay  = $day.' 0:0:0';
		echo $newDay;
        $newTime = strtotime($newDay);
		echo $newTime;
		exit;
$time = time();
echo $time;
exit();
$a = date('Y-m-d',$time);
$b = $a.' 0:0:0'; 

echo strtotime($b);
exit();
$a = '123';
$b = explode(',',$a);
var_export($b);
exit;

$a = false;
if (empty($a)) {
	echo 1;
}
exit;
$url = "http://m-api.xcar.com.cn/thirdparty/qiniu/tokenUrl";
function changeImageHttps ($url)
{
    if (preg_match('/http:/', $url))	
    {
        $url = str_replace('http:','https:',$url);
        echo $url;
    }
    echo $url;
}

changeImageHttps($url);




exit;
$a = 1544889600;
$a = 1545062400;
$c = date('y-m-d H:i:s',$a);
echo $c;
exit;
$b = '%E6%B2%BD%E6%BA%90%E5%8E%BF4%5Btextcard%5D%E6%B2%BD%E6%BA%90%E5%8E%BF%E6%9C%8D%E5%8A%A1%E7%A1%AE%E5%AE%9E%EF%BC%88%E6%AD%A3%E5%9C%A8%E5%B0%8F%E5%A6%B9%EF%BC%89%E5%95%AA%E5%95%AA%E5%95%AA%E6%89%BE%E4%B8%80%E6%99%9A%E4%B8%8A%E5%85%A8%E5%A5%97%E9%82%A3%E6%9C%89%E5%A4%9A%E5%B0%91%E7%9C%9F%5B%2Ftextcard%5D%5Bpiccard%5D%5B%2Fpiccard%5D';
echo urldecode($b);
exit;
$a = '%E6%B2%BD%E6%BA%90%E5%8E%BF3%5Btextcard%5D%E6%B2%BD%E6%BA%90%E5%8E%BF%E6%9C%8D%E5%8A%A1%E7%A1%AE%E5%AE%9E%EF%BC%88%E6%AD%A3%E5%9C%A8%E5%B0%8F%E5%A6%B9%EF%BC%89%E5%95%AA%E5%95%AA%E5%95%AA%E6%89%BE%E4%B8%80%E6%99%9A%E4%B8%8A%E5%85%A8%E5%A5%97%E9%82%A3%E6%9C%89%E5%A4%9A%E5%B0%91%E7%9C%9F%5B%2Ftextcard%5D%5Bpiccard%5D%5B%2Fpiccard%5D';
echo urldecode($a);
exit;
$a = date('y-m-d H:i:s',1545881177);
echo $a;exit;
$a = '2018-12-24 8:0:0';
$b = '2018-12-24 9:0:0';
echo strtotime($a);
echo '----';
echo strtotime($b);
exit;

$test_string="123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789";
var_dump($test_string);//原字符串长度

var_dump(gzcompress($test_string));//gzcompress压缩后
var_dump(gzdeflate($test_string));//gzdeflate压缩后
var_dump(gzencode($test_string));//gzencode压缩后

var_dump(gzuncompress(gzcompress($test_string)));//gzcompress压缩后再解压缩回来
var_dump(gzinflate(gzdeflate($test_string)));//gzdeflate压缩后再解压缩回来
var_dump(gzdecode(gzencode($test_string)));//gzencode压缩后再解压缩回来
exit;

$b = 'http://image1.xcarimg.com/attachments/my/0/79/99/403.jpg?t=1542702710';

$a = file_exists($b);
var_export($a);

$c = file_get_contents($b);
var_export($c);

$b = '';
$d = getimagesize($b);
var_export($d);
exit;

$a = 'http://live.xcar.com.cn/live/889.html';
$b ='/\/(\d*)\.html/';
 preg_match($b, $a, $linkInfo);
 var_export($linkInfo);
exit;
$a = '哈';
$contentLen = strlen(mb_convert_encoding($a,'GBK','UTF-8'));
echo $contentLen;
exit;
$a = '2018-11-27 18:32:29';
echo strtotime($a);
exit;
$arr = array(1351,1353,1400,1340,1343,1331,1402,1341,1329,1171,1173,1973,1974,979,1464,1694,1467,1466,1498,1499,1328,1404,1405,1332,1505,1633,1566,1573,1572,1569,1629,1687,1686,1630,1689,1647,1987,1993,1991,1714,1711,1904,1912,1980,1907,1915,1986,1989,1990,1913,1997,1994,1992,1903,1634,1565,1758,1759,1080,1275,1629,1573,1572,1571,1569,1467,1566,1498,1499,1080,1275,1569,1340,1400,1343,1331,1402,1341,1332,1343,1331,1570,1571,1630,1710,1711,1572,1733,1774,1873,1774,1980,1907,1915,1986,1989,1990,1565,1974,1569,1904,1694,1467,1466,1634,1328,1505,1973,1328,1400,1343,1994,1992,1402,1341,1343,1903,1907,1987,1993,1991,1711,1647,1694,1714,1464,1329,1331,1351,1353,1758,1759,1689,1464,1647,979,1689,1647,1711,1629,1400,1343,1402,1341,1343,1273,1404,1405,1687,1686,1984,1466,1467,1573,1572,1633,1714,1774,1873,1472);
$newArr = array_unique($arr);
var_export($newArr);
exit;
$a = '我';
echo mb_strlen($a);
exit;
$b = strlen($a);
$c = mb_convert_encoding($a,'GBK','UTF-8');
echo $b;
echo strlen($c);
exit;
$a = '习大大哈哈';
$b = '***';
$c = '习大大';
$c = str_replace($a,$c,$b);
echo $c;
exit;
$a = '';
$b = mb_convert_encoding($a,'UTF-8','GBK');
var_dump($b);
exit;
$files = scandir('./');
var_dump($files);
exit;
echo date('-z',time());

echo date('-z',mktime(0,0,0,1,1,2018));

$day = '2018-4-13';
//统计文件中.后面的网址出现多少次
$file = './cc.txt';
echo strrchr($file,'.');
exit;
$file_infos = file($file);
$new_arr = [];
foreach($file_infos as $file_info) {
	$num = strpos($file_info,'.');
	$str = substr($file_info,$num+1,$num+5);
	if(array_key_exists($str,$new_arr)){
		$new_arr[$str]++;
	}else{
		$new_arr[$str] = 1;
	}
}
var_dump($new_arr);
exit();
$a = '123';

$len = strlen($a);
$str = '';
for($i = $len;$i>=0;$i--){

	$str .= $a[$i];

}
echo $str;
exit;
echo date('y-m-d H:i:s',strtotime("-1 day"));




exit;
$a = '2+1+1';
$b = 100;
$c = $a + $b;
echo $c;
exit;
$a = [1=>1,2=>2];
$b = [3=>3,2=>4];
$c = array_merge($a,$b);

$d = ['a'=>1,'c'=>3];
$e = ['b'=>2,'c'=>5];
$f = array_merge($d,$e);


var_dump($f);


exit;
$a = '1234567';
$b = str_split($a);

$c = join($b);
echo $c;
exit;
echo strlen($a);
echo mb_strlen($a);

exit;
$str = '';
for($i =1; $i<64;$i++){
	$str .= 1;
}
$str .= 0;
echo bindec($str);
exit;
setcookie('aa',111,time()+300);

var_dump($_COOKIE);
exit;



//求最大连接数
$str = '28953456323';
$num = '';
$new_arr = [];

for($i = 0;$i<strlen($str) - 1;$i++) {
	if($str[$i] < $str[$i+1]) {
		if(empty($num)) {
			$num .= $str[$i].$str[$i+1];
		} else {
			$num .= $str[$i+1];
		}
		if($i+1 == strlen($str) -1) {
			if(!empty($num)) {
				$new_arr[] = $num;
			}
		}
	} else {
		if(!empty($num)) {
			$new_arr[] = $num;
		}
		$num = '';
	}
}









var_dump($new_arr);

exit;
function odd($var) {
	return ($var % 2 == 1);
}

function even ($var) {
	return ($var % 2 == 0);
}

$array1 = ['a'=> 1,'b'=>2,'c'=>3,'d'=>4,'e'=>5];
$array2 = [6,7,8,9,10,11,12];

echo "odd:\n";
print_r(array_filter($array1,"odd"));
echo "even:\n";
print_r(array_filter($array2,"even"));

exit;






for ($i = 0;$i < strlen($str) - 1;$i++){
	if ($str[$i+1] > $str[$i]) {
		if(empty($num)) {
			$num .= $str[$i].$str[$i+1];
		} else {
			$num .= $str[$i+1];
		}
		if($i+1 == strlen($str) - 1) {
			if(!empty($num)) {
				$new_arr[] = $num;
			}
		}	
	} else {
		if (!empty($num)) {
			$new_arr[] = $num;
		}
		$num = '';
	}	

}
var_dump($new_arr);

exit;
/**
//curl 
$ch = curl_init() //初始化
//设置选项，包括url
curl_setopt($ch,CURLOPT_URL,"https://www.imooc.com");
curl_setopt($ch,CURLOPT_RETURNTRANDSFER,1); //将curl_exec() 获取的信息以文件流的形式返回，而不是直接输出
curl_setopt($ch,CURLOPT_HEADER,1);
$output = curl_exec($ch);  //执行并获取html文档内容
//释放curl
curl_close($ch);
echo $out_put;


exit;
//生成uuid
function create_uuid($prefix = "") {
	$str = md5(uniqid(mt_rand(),true));
	$uuid = substr($str,0,8).'_';
	$uuid .= substr($str,8,4).'_';
	$uuid .= substr($str,12,4).'_';
	$uuid .= substr($str,16,4).'_';
	$uuid .= substr($str,20,12);
	return $prefix.$uuid.'_'.$str;

}

echo create_uuid();



exit;
$a = 3;
$a+=$a-=$a*$a;

echo $a;
exit;
//把数组中的true变成‘true’ 不破坏表结构
$arr = ['a',[2,true,''],'123',123,false,[1,['c','d'],'32']];


function aac (&$array) {
	
	foreach($array as $key => &$arr) {

		if(is_array($arr)){
			aac($arr);
		}else{
			if(!is_string($arr)) {
			if (is_bool($arr)){
				if(!$arr) {
					$arr = "'false'";
				}else{
					$arr = "'true'";
				}
			}else{
				$arr = (string)$arr;
			}
			}
		}
	}
	return $array;
}

$b = aac($arr);
var_dump($b);

exit;

function test1($a = 0){
$a++;
if($a<10){
	echo $a;
	test1($a);
}
}
exit;
/**
写一个function实现数组内每个元素之间的加法的迭代运算
数组元素全部为自然数
程序要求打印出数组每个数组元素相互之间各种可能性加法
$data = [1,2,3];
包括元素自己本身 1+1=2,1+2=3,1+3=4
*/

$data = [1,2,3];

for($i = 0;$i<count($data);$i++){
	for($j = 0;$j<count($data);$j++){
		$data_num = $data[$i] + $data[$j];	
		$str ="{$data[$i]}+{$data[$j]}={$data_num}";
		echo $str;
	}

}
exit;
/*
计算数组中重复出现最多的元素，次数相同的取最大值
*/
$a = [123,234,345,234,567,123,234,234,22,22,22,44,44,44];


$b = array_count_values($a);
arsort($b);
$c = current($b);
$ckey = key($b);
unset($b[$ckey]);
$arr = [];
foreach($b as $key=>$val) {
	if($c == $val){
		$arr[] = $key;	
	}else{
		break;
	}	
}
$arr[] = $ckey;
$max_num = max($arr);

var_dump($max_num);


exit;

//打印常量

define('AAA',123);


var_dump(AAA);




exit;
//对象转换数组
$a = [1=>2,3=>3,4=>4,5=>1,6=>5];




$b = json_encode($a);

$c = json_decode($b);

//var_dump((array)$c);
var_dump($c);
foreach($c as $a=>$s) {

	

}









exit;
//循环删除文件
function deldir($path = '') {
	$dir = opendir($path);
	while(($file = readdir($dir)) !== false) {
		$sub_dir = $path.'/'.$file;
		if($file == '.' || $file == '..') {
			continue;
		}elseif(is_dir($sub_dir)) {
			deldir($sub_dir);
		}elseif(is_file($sub_dir)){
			unlink($sub_dir);
			echo '删除文件'.$file.'成功';
		}
	}
	

}



deldir('/Users/ye/demo/test/ccc');


exit;
//格式化数字 123，456，789
$a = 1234567890;

echo number_format($a);




exit;
$a = 1;


exit;

$a = 3;
$b = 4;
if($a || $b = 5) {

}

echo $b;
exit;




$a = ['age' => 19];

//echo "you age is ".{$a['age']}."?";

echo 'you age is'.$a['age'].'?';

//echo "you age is $a['age']";

echo "you age is {$a['age']}?";




exit;
$a = [1=>5,5=>8,22,2=>'8',81];

echo $a[7];
echo $a[6];
echo $a[3];

var_dump($a);
exit;
//去掉html标签
$a = 'aaaa<em>bbb</em>cccc';
echo strrev($a);
$max = 100;

function aa ($a,$max) {
	$b = strip_tags($a);
	echo $b.'<br>';
	if($max > strlen($b)) {
		echo 'max > a';
	}
}

echo $_SERVER['REMOTE_ADDR'];

echo $_SERVER['SERVER_NAME'];
